using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.ObjectBuilder;
using Microsoft.Practices.CompositeWeb;
using System.Transactions;
using GC2.Entities.Admin;
using GC2.ExceptionHandler.Services;
using GC2.DataAccess.DAAdmin;

namespace GC2.Bussines.BMAdmin
{
    public class BMSubRubros
    {
        public BMSubRubros(string coneccion) 
        {
            this.Connection = coneccion;
        }

        private string connection = "";
        public string Connection
        {
            get { return connection; }
            set { connection = value; }
        }

        private SubRubros oSubRubro = new SubRubros();
        private List<SubRubros> listaSubRubros = new List<SubRubros>();
        private DASubRubros daSubRubros = new DASubRubros();

        #region BMSubRubrosSearch
        public List<SubRubros> BMSubRubrosSearch(SubRubros subRubro)
        {
            try
            {
                listaSubRubros = daSubRubros.DASubRubrosSearch(connection, subRubro);
                return listaSubRubros;
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion

        #region BMSubRubrosInsert
        public SubRubros BMSubRubrosInsert(SubRubros subRubro)
        {
            try
            {
                subRubro = daSubRubros.DASubRubrosInsert(connection, subRubro);
                return subRubro;
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion

        #region BMSubRubrosUpdate
        public void BMSubRubrosUpdate(SubRubros subRubro)
        {
            try
            {
                daSubRubros.DASubRubrosUpdate(connection, subRubro);
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion
    }
}
